home *** CD-ROM | disk | FTP | other *** search
- Path: s02.pavilion.co.uk!usenet
- From: AJRobb@pavilion.co.uk (Andy J Robb)
- Newsgroups: comp.lang.c++
- Subject: Re: Leap year
- Date: Tue, 05 Mar 1996 03:37:11 GMT
- Organization: Pavilion Internet plc
- Message-ID: <4hgcrs$2kl@s02.pavilion.co.uk>
- References: <3135A7F2.2120@hiwaay.net> <4hbiln$899@sam.inforamp.net>
- NNTP-Posting-Host: poolc35.pavilion.co.uk
- X-Newsreader: Forte Free Agent 1.0.82
-
- rmorin@inforamp.net (Randy Charles Morin) wrote:
-
- >In article <3135A7F2.2120@hiwaay.net>, Lance Perry <lperry@hiwaay.net> wrote:
- >>Can someone be kind enough to post the formula for Leap Year
- >>or point me to the place where this can be found?
- >>
- >>lperry@hiwaay.net
-
- >bool IsLeapYear(int x)
- >{
- > return ((x&4) && ((!(x&100)) || (x&1000)));
- >}
-
- >I hope I got everything right.
-
- -----BEGIN PGP SIGNED MESSAGE-----
-
- Sorry guy, no you didn't.
-
- (!(x%400)) || ((x%100) && (!(x%4))
-
- My main point, it that every 400 years is currently defined as a leap
- year (not 1000 years as you indicated) whereas, at every other 100
- years it is not. Thus 2000 is a leap year, as would be 2400.
- Whereas, 1800, 1900 were not leap years. Generally, systems dealing
- in current time are safe to use:
-
- !(x & 3)
-
- There will not be a potential problem until 2100, and whos to say we
- will still be using a Christian calender then.
-
- Regards,
- Andy Robb.
-
- -----BEGIN PGP SIGNATURE-----
- Version: 2.6.2i
-
- iQCVAwUBMTu2pJPl4P16x9sNAQEf6gQAoSBrott9tJ41oqrGoKYaUQ/hL2IXL6rC
- ++ienee2EprqxkOp466PFRnHEZPAbOB05KjEKs0/2UShZM5z2Cs1FnQlglrCuZVB
- K8DERgflk4e53xm/xrBfrHKW3LCvI1B4qwkvECmMPYt0fANrhVZs1aF9vTbpE6Bf
- 1I4qR+ga2P8=
- =i21/
- -----END PGP SIGNATURE-----
-
-
-